home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Views / Standard Views / ProgressView.cp < prev    next >
Text File  |  1997-06-28  |  2KB  |  94 lines

  1. // ProgressView.cp
  2.  
  3. #ifndef ProgressView_h
  4. #include "ProgressView.h"
  5. #endif
  6. #ifndef Progress_h
  7. #include "Progress.h"
  8. #endif
  9. #ifndef ViewMap_h
  10. #include "ViewMap.h"
  11. #endif
  12.  
  13. ProgressView::ProgressView( const Progress& theProgress )
  14.   : progress( theProgress ),
  15.      ear( theProgress, *this, &ProgressView::UpdateSplit ),
  16.      split( 0 )
  17.   {
  18.   }
  19.  
  20. ProgressView::~ProgressView()
  21.   {
  22.   }
  23.  
  24. void ProgressView::GainMapping()
  25.   {
  26.     UpdateSplit();
  27.     View::GainMapping();
  28.   }
  29.  
  30. void ProgressView::ChangeBounds( Rectangle oldBounds )
  31.   {
  32.     UpdateSplit();
  33.     View::ChangeBounds( oldBounds );
  34.   }
  35.  
  36. void ProgressView::UpdateSplit()
  37.   {
  38.     if ( !progress.TotalKnown() || !Mapped() )
  39.         return;
  40.     
  41.     ViewMap map( *this, ViewMap::includeInvalid );
  42.      
  43.     int16 newSplit = progress.Fraction() * double( map.Bounds().Width() ) + 0.5;
  44.     
  45.     if ( split != newSplit )
  46.       {
  47.         split = newSplit;
  48.         Draw( map );
  49.         map.Validate();
  50.       }
  51.   }
  52.  
  53. void ProgressView::Draw( const ViewMap& map ) const
  54.   {
  55.     Rectangle past( map.Bounds() );
  56.     Rectangle future( map.Bounds() );
  57.     
  58.     past.right = past.left + split;
  59.     future.left = past.right;
  60.     
  61.     PaintRect( &past );
  62.     EraseRect( &future );
  63.   }
  64.  
  65. uint16 ProgressView::MinimumWidth() const
  66.   {
  67.     return 22;
  68.   }
  69.  
  70. uint16 ProgressView::MinimumHeight() const
  71.   {
  72.     return 3;
  73.   }
  74.  
  75. uint16 ProgressView::ReasonableWidth() const
  76.   {
  77.     return 188;
  78.   }
  79.  
  80. uint16 ProgressView::ReasonableHeight() const
  81.   {
  82.     return 11;
  83.   }
  84.  
  85. uint16 ProgressView::BestWidth() const
  86.   {
  87.     return 188;
  88.   }
  89.  
  90. uint16 ProgressView::BestHeight() const
  91.   {
  92.     return 11;
  93.   }
  94.